package cn.yunhe.servlet;

import cn.yunhe.pojo.BoardDemo;
import cn.yunhe.service.BoardService;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

public class QueryBoardsServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        BoardService boardService = new BoardService();
        List<BoardDemo> listboard =  boardService.searchAllBoard();
        if(listboard !=null &&  listboard.size()>0){
            req.setAttribute("listboard",listboard);
            req.getRequestDispatcher("editNews.jsp").forward(req,resp);
        }
    }
}
